<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="/styles/base.css" rel="stylesheet" type="text/css">
    <link href="/styles/public.css" rel="stylesheet" type="text/css">
    <link href="/js/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <link href="/js/datepicker/datepicker.css" rel="stylesheet">
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.min.js"></script>
    <script type="text/javascript" src="/js/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>
    <script type="text/javascript" src="/js/public.js"></script>

    <link type="text/css" rel="stylesheet" href="/js/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css"/>
    <script type="text/javascript" src="/js/plugins/bootstrap-tagsinput/bootstrap-tagsinput.js"></script>
</head>
<script>
    $(function () {
        // 初始化富文本编辑器
        ue = UM.getEditor('editor', {
            textarea: "content", //表单文本域的name
            imageUrl: "/question/contentImage",//图片上传路径
            imageFieldName: "upfile",
            imagePath: ''
        });


        //发布问题
        $("._j_publish").click(function () {
            //标题
            var title = $("._j_title").val();
            //内容
            var content = ue.getContent();
            //目的地
            var destId = $("#region").val();
            //目的地
            var tags = $("#tagsinputval").val();

            //标签
            if (title.length < 3) {
                alert("标题不能少于3字");
                return;
            }
            if (!content) {
                alert("问题描述不能为空");
                return;
            }
            if (destId < 0) {
                alert("请选择目的地");
                return;
            }

            $.post("/question/save", {title: title, content: content, 'dest.id': destId, tagsName: tags}, function (data) {
                if (data.code == 102) {   //后台判断如果没有登录，返回102状态码
                    alert(data.msg);    //并弹窗提示
                }
                if (data.success) {
                    alert("发布成功");
                    window.location.href = "/question/wenda";  //发布完刷新页面
                }
            })
        })


    })

</script>


<body>
<div class="lww_header">
    <div class="header_wrap">
        <div class="header_logo">
            <a href="javascript:;" class="lww_logo"></a>
        </div>
        <ul class="header_nav">
            <li><a href="/">首页</a></li>
            <li><a href="/destination">目的地</a></li>
            <li><a href="/strategy">旅游攻略</a></li>
            <li><a href="javascript:;">去旅行<i class="icon_caret_down"></i></a></li>
            <li><a href="/travel">游记</a></li>
            <li><a href="javascript:;">酒店</a></li>
            <li><a href="/question/wenda">社区<i class="icon_caret_down"></i></a></li>
        </ul>
        <div class="header_search">
            <input type="text"/>
            <a class="icon_search"></a>
        </div>
        <div class="login_info">
            <div class="head_user">
                <a href="javascript:;">
                    <img src="/images/user.png"/>
                    <i class="icon_caret_down"></i>
                </a>
            </div>
            <div class="header_msg">
                消息<i class="icon_caret_down"></i>
            </div>
            <div class="header_daka">
                <a href="javascript:;">打卡</a>
            </div>
        </div>
    </div>
    <div class="shadow"></div>
</div>
<div class="wrapper">
    <div class="qt-container clearfix">
        <div class="qt-main">
            <div class="crumb">
                <a href="/question/wenda">旅游问答</a> &gt; <span>我要提问</span>
            </div>
            <div class="qt-tit">
                <h5>问题标题</h5>
                <div class="qt-con">
                    <input type="text" placeholder="标题不小于3字" class="_j_title">
                    <span class="count"><span class="_j_title_num">0</span>/80 字</span>
                    <span class="_j_min_num hide">10</span>
                    <span class="error err-tips _j_title_error">标题不能少于3字</span>
                </div>
            </div>
            <h5>请选择目的地</h5>
            <div class="pi-dropdown " style="text-align: left">
                <select name="dest.id" data-placeholder="请选择目的地" id="region" style="width: 150px;">
                    <option value="-1">请选择目的地</option>
                <#list dests! as d>
                    <option value="${d.id!}">${d.name!}</option>
                </#list>
                </select>
            </div>
            <br>


            <div class="form-group">
                <label class="col-sm-2 control-label">标签：</label>
                <div class="col-sm-8">
                    <input name="tags" id="tagsinputval" class="form-control tagsinput " value="${tags!}"
                           data-role="tagsinput" placeholder="输完后按回车"/>
                </div>
            </div>

            <div class="qt-interest _qa_block" id="_qa_interest">
                <h5>选择兴趣标签</h5>
                <div class="qt-con _j_interest_list">
                    <dl class="interest-description">
                        <dt><i></i><span>什么是兴趣标签</span></dt>
                        <dd>兴趣标签是一个问题的类型，它有助于为你的问题匹配擅长该类问题的蜂蜂回答。目前仅开放了以下几个话题，更多类型我们会逐步开放。</dd>
                    </dl>
                    <div class="interest-tags">
                        <a class="btn-interest _j_interest" data-id="1016"><i></i>自驾</a>
                        <a class="btn-interest _j_interest" data-id="1052"><i></i>亲子</a>
                        <a class="btn-interest _j_interest" data-id="1040"><i></i>摄影</a>
                        <a class="btn-interest _j_interest" data-id="1036"><i></i>美食</a>
                        <a class="btn-interest _j_interest" data-id="1044"><i></i>滑雪</a>
                        <a class="btn-interest _j_interest" data-id="1068"><i></i>购物</a>
                        <a class="btn-interest _j_interest" data-id="1112"><i></i>徒步</a>
                        <a class="btn-interest _j_interest" data-id="1048"><i></i>潜水</a>
                        <a class="btn-interest _j_interest" data-id="1096"><i></i>骑行</a>
                    </div>
                </div>
            </div>

            <div class="qt-details">
                <h5><a title="添加问答内容" class="icon active" id="_j_show_content"></a>问题详细内容</h5>
                <script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
                </div>
                <div class="publish_question">
                        <a class="qt-post-btn _j_publish" title="发布问题">发布问题</a>
                        </div>
                        </div>
                        <div class="qt-sider">
                        <div class="qts-tit">提问的正确姿势</div>
                        <div class="qts-con">
                        <p>1.问题要【具体】【真实】【诚恳】，问题较多，需全面阐述时，可以添加问题补充。结伴/交易/与旅行无关的提问将被删除。</p>
                <p>2.给问题添加目的地，并打上正确的标签将有助于更快地获得回答。</p>
                </div>
                </div>
                </div>
                </div>
                </body>

                </html>